package com.astar.service.impl;

import com.astar.entity.CustomMenu;
import com.astar.entity.Role;
import com.astar.mapper.RoleMapper;
import com.astar.service.IRoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 角色信息表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2020-01-17
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Autowired
    private RoleMapper roleMapper;


    @Override
    public List<Role> selectList(String name) {
        if (name==null){
            name="";
        }
        QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("role_name",name);
        List<Role> roles = roleMapper.selectList(queryWrapper);
        return roles;
    }

    @Override
    public int delete(Role role) {
        return roleMapper.updateById(role);
    }

    @Override
    public List<CustomMenu> selectAllTree() {
        return roleMapper.selectAllTree();
    }
}
